import ajax from './ajax'

export default {

  loadOneUser(userId, onSuccess) {
    ajax.get('/douban/users/' + userId)
        .then(onSuccess);
  },

  loadUsers(offset, limit, onSuccess) {
    ajax.get('/douban/users?offset=' + offset + '&limit=' + limit)
        .then(onSuccess);
  },

  loadUserTrend(onSuccess) {
    ajax.get('/douban/users/trend')
        .then(onSuccess);
  },

  tagUser(userId, tags, onSuccess) {
    ajax.post('/douban/users/'+userId+'/tags', {
      tag: tags
    })
    .then(onSuccess)
    .catch(err=>{console.log(err)});
  },

  blockUser(userId, cause, blockDays, onSuccess) {
    ajax.post('/douban/users/'+userId+'/black', {
      blockDays:blockDays,
      cause:cause
    })
    .then(onSuccess)
    .catch(err=>{console.log(err)});
  }
}